//
//  NSBundle+Demo.m
//  Demo
//
//  Created by Tang Boss on 12/12/2017.
//  Copyright © 2017 HandeIdealVison. All rights reserved.
//

#import "NSBundle+Demo.h"
#import <objc/runtime.h>

@implementation NSBundle (Demo)
+ (void)load {
    method_exchangeImplementations(class_getInstanceMethod(self, @selector(bundleIdentifier)), class_getInstanceMethod(self, @selector(swizzle_bundleIdentifier)));
}

- (NSString *)swizzle_bundleIdentifier {
    if ([self crack]) {
        return @"com.zyebank.pmobile";
    }
    
    return [self swizzle_bundleIdentifier];
}

static char kCrack;
- (void)setCrack:(BOOL)enabled {
    objc_setAssociatedObject(self, &kCrack,@(enabled), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (BOOL)crack {
    return [objc_getAssociatedObject(self, &kCrack) boolValue];
}
@end
